import Platform
import pygame
image=pygame.image.load("aerostat.jpg")
image.set_colorkey((137,44,75))

class Aerostat(Platform.Platform):
	def __init__(self,pos=(0,0),im=image):
		Platform.Platform.__init__(self,pos,im)
		self.max_altitude=pos[1]
	def process(self):
		if self.max_altitude>self.pos[1] and len(self.boundedList)==0:
			self.pos=[self.pos[0],self.pos[1]+10]
			if self.pos[1]>self.max_altitude:
				self.pos=[self.pos[0],self.max_altitude]
		elif len(self.boundedList)>0:
			m=0
			for passenger in self.boundedList:
				m=m+passenger.getMass()
			self.descend(m)
	def descend(self,mass):
		dy=0.1*mass
		self.pos=[self.pos[0],self.pos[1]-dy]
		for passenger in self.boundedList:
			passenger.y=passenger.y-dy
	def drawingInformation(self):
		return (self.pos[0]-0.5*self.getWidth(),self.pos[1]+self.getHeight()),self.image
	def xLanding(self,objecto):
		eps=15
		if not objecto.dead and (self.rightCondition(objecto) or self.leftCondition(objecto) or self.upperCondition(objecto) or self.lowerCondition(objecto)):
			objecto.reposition(self.pos[0],self.pos[1]-objecto.getHeight())
			self.boundX(objecto,False)
	def hasFallenOff_x(self,objecto):
		if objecto.y_bound:
			self.unbound(objecto)
			self.descend(-2*objecto.getMass())
	def isSlim(self):
		return True
	def yLanding(self,objecto):
		pass
	def upperSide(self):
		return self.pos[1]+7
	def lowerSide(self):
		return self.pos[1]-7
	def leftSide(self):
		return self.pos[0]-7
	def rightSide(self):
		return self.pos[0]+7
	def slideDown(self,him):
		return 0
	def swingable(self):
		return False